import CoworkContent from './cowork/content/';
import CoworkTagDialog from './cowork/dialog/CoworkTagDialog';
import { inject, observer } from 'mobx-react';

@inject('coworkMainStore')
@observer
class CoworkSingle extends React.Component {
  constructor(props) {
    super(props);
  }
  componentDidMount() {
    let { params, coworkMainStore } = this.props;
    coworkMainStore.init();
    let { coworkId, floorNum } = params;
    coworkMainStore.chooseCowork(coworkId, floorNum, this.setTitle);
  }
  componentWillReceiveProps(nextProps) {
    if (nextProps.params.coworkId != this.props.params.coworkId || nextProps.params.floorNum != this.props.params.floorNum) {
      const { coworkMainStore } = nextProps;
      coworkMainStore.chooseCowork(nextProps.params.coworkId, nextProps.params.floorNum, this.setTitle);
    }
  }
  render() {
    return (
      <div className="h100">
        <div className="wea-cowork-main single">
          <CoworkContent ecId={`${this && this.props && this.props.ecId || ''}_CoworkContent@pm4vl2`} />
          <CoworkTagDialog ecId={`${this && this.props && this.props.ecId || ''}_CoworkTagDialog@k3850f`} />
        </div>
      </div>
    );
  }
  setTitle = (cowork) => {
    document.title = cowork.itemsVO.name;
  }
}

export default CoworkSingle;
